package com.example.myapplication.utils;

import java.util.HashMap;
import java.util.jar.Attributes;

public class NameCreator {

    private static NameCreator nameCreator;

    HashMap<String, Integer> nameMap = new HashMap<>();
    HashMap<String, Integer> nameMap1 = new HashMap<>();

    public static NameCreator getInstance() {
        if (nameCreator == null) {
            nameCreator = new NameCreator();
        }
        return nameCreator;
    }

    private NameCreator() {

    }

    public String getName(String className,int hashcode) {

        Integer index = nameMap.get(className);

        if (index == null) {
            index=1;
            nameMap.put(className, index);
        }else {
            index++;
            nameMap.put(className, index);
        }
        return className+"_"+index+"  :";
    }

    public void clear(){
        nameMap.clear();
    }

}
